//
//  UIButton + Ext.swift
//  WeiboSwift
//
//  Created by xiaokui wu on 9/9/16.
//  Copyright © 2016 wxk. All rights reserved.
//

import UIKit

extension UIButton
{
    convenience init(imageName: String, bgImageName: String)
    {
        self.init()// 便利构造方法必须调用指定构造方法，因为指定构造方法必须对所有属性初始化
        // 前景图片
        setImage( UIImage(named: imageName), forState: .Normal)
        setImage( UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        // 背景图片
        setBackgroundImage(UIImage(named: bgImageName), forState: .Normal)
        setBackgroundImage(UIImage(named: bgImageName + "_highlighted"), forState: .Highlighted)
        // 尺寸跟图片一样大
        sizeToFit()
    }
}
